package com.kgc.study;

public class Master {
    private String name;
    private int money;

    public Master() {
    }

    public Master(String name, int money) {
        this.name = name;
        this.money = money;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getMoney() {
        return money;
    }

    public void setMoney(int money) {
        this.money = money;
    }

    //以父类作为方法的形参的意思：接收不同的子类对象（以不变应万变）
    public void cure(Pet pet){
        pet.toHospital();
    }


    /*public void cure(Pet pet){
        if(pet.getHealth() < 50){
            if(pet instanceof  Cat){
                System.out.println("打针、输液 ...");
                pet.setHealth(70);
            }
            else if(pet instanceof  Dog){
                System.out.println("打针、吃药 ...");
                pet.setHealth(60);
            }
            else if(pet instanceof Penguin){
                System.out.println("打针、疗养 ...");
                pet.setHealth(80);
            }
        }
    }*/

   /* public void cure(Dog dog){
        if(dog.getHealth() < 50){
            System.out.println("打针、吃药 ...");
            dog.setHealth(60);
        }
    }

    public void cure(Cat cat){
        if(cat.getHealth() < 50){
            System.out.println("打针、输液 ...");
            cat.setHealth(70);
        }
    }

    public void cure(Penguin penguin){
        if(penguin.getHealth() < 50){
            System.out.println("打针、疗养 ...");
            penguin.setHealth(80);
        }
    }*/
}
